package com.videolist.lingling.view;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.widget.RelativeLayout;

/**
 * Created by Administrator on 2016/10/17/017.
 */

public class SelectedRelativeLayout extends RelativeLayout {
    private Drawable mFloatDrawable;
    private Rect mTempRect = new Rect();

    public SelectedRelativeLayout(Context context) {
        this(context, null, 0);
    }

    public SelectedRelativeLayout(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public SelectedRelativeLayout(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
//        mFloatDrawable = getResources().getDrawable(R.drawable.item_float_rectangle);
    }

    @Override
    protected void dispatchDraw(Canvas canvas) {
        super.dispatchDraw(canvas);
        if (hasFocus()) {
            if (mFloatDrawable != null) {
                final int w = getMeasuredWidth();
                final int h = getMeasuredHeight();
                mFloatDrawable.getPadding(mTempRect);
                mFloatDrawable.setBounds(-mTempRect.left, -mTempRect.top,
                        w + mTempRect.right, h + mTempRect.bottom);
                mFloatDrawable.draw(canvas);
            }
        }
    }

}